// 自定义指令
import Vue from 'vue'

Vue.directive('animation',{
  inserted(el, target) {
    if ('IntersectionObserver' in window) {
      let io = new IntersectionObserver(entries => {
        if(entries[0].isIntersecting && [...el.classList].indexOf('already') < 0){
          el.classList.add('animated')
          el.classList.add('fadeInUp')
        }
      })
      io.observe(el)
    }
    else {
      el.classList.add('cardShow')
    }
  }
})


// 过滤器
Vue.filter('changeDate', (value) => {
  if (!value) return ''
  return value.substr(0,10)
})
